﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using nStruct;

namespace LDS1000_V1
{
	public partial class frmRS232Setup : Form
	{

		Com_Conf_Struct ComPort=new Com_Conf_Struct();
		
		public frmRS232Setup()
		{
			InitializeComponent();
		}
		private void frmRS232Setup_Load(object sender, EventArgs e)
		{
			frmMain fMain = this.Owner as frmMain;
			ComPort = fMain.Com_Conf;
			
			cmbRS232.Items.Clear();
			for (int i = 0; i < 20; i++)
			{
				cmbRS232.Items.Add( "COM"+(i+1).ToString());
			}
			cmbRS232.Text = ComPort.PortName[0];

			cmbSpeed.Items.Clear();
			cmbSpeed.Items.Add("2400");
			cmbSpeed.Items.Add("4800");
			cmbSpeed.Items.Add("9600");
			cmbSpeed.Items.Add("19200");
			cmbSpeed.Items.Add("38400");
			cmbSpeed.Items.Add("57600");
			cmbSpeed.Items.Add("115200");
			cmbSpeed.SelectedIndex = 5;
		}
		private void frmRS232Setup_FormClosed(object sender, FormClosedEventArgs e)
		{
			ComPort.PortName[0] = cmbRS232.Text;
			ComPort.Speed[0] = Convert.ToInt32(cmbSpeed.Text);
			frmMain fMain = this.Owner as frmMain;
			fMain.Com_Conf = ComPort;
			fMain.Comport_Setup();
			fMain.Enabled = true;
		}
	}
}
